// textureDlg2.cpp : implementation file
//

#include "stdafx.h"
#include "CGWork.h"
#include "textureDlg2.h"
#include "afxdialogex.h"
#include "ObjectTextureDlg.h"


// textureDlg2 dialog

IMPLEMENT_DYNAMIC(textureDlg2, CDialogEx)

textureDlg2::textureDlg2(CWnd* pParent /*=NULL*/)
	: CDialogEx(textureDlg2::IDD, pParent)
{

}

textureDlg2::~textureDlg2()
{
}

void textureDlg2::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_LIST1, objNames);
	//DDX_Control(pDX, IDC_LIST2, typeNameList);
}


BOOL textureDlg2::OnInitDialog(){
	CDialog::OnInitDialog();
	CString str;
	for (int i = 0 ; i< objNameArray.size();i++){
		str = (objNameArray[i] + " - " + objTypeArray[i]).c_str();
		objNames.AddString(_T(str));
		//typeNameList.AddString(_T("PHONG"));

		//objTypeArray.push_back("PHONG");
		//textureAns.push_back(2);

	}


	return true;
}

BEGIN_MESSAGE_MAP(textureDlg2, CDialogEx)
	/*ON_BN_CLICKED(IDC_BUTTON1, &textureDlg2::OnBnClickedButton1)
	ON_BN_CLICKED(IDC_BUTTON2, &textureDlg2::OnBnClickedButton2)
	ON_BN_CLICKED(IDC_BUTTON3, &textureDlg2::OnBnClickedButton3)
	ON_BN_CLICKED(IDC_BUTTON4, &textureDlg2::OnBnClickedButton4)
	ON_BN_CLICKED(IDC_BUTTON5, &textureDlg2::OnBnClickedButton5)
	ON_BN_CLICKED(IDC_BUTTON6, &textureDlg2::OnBnClickedButton6)
	ON_BN_CLICKED(IDC_BUTTON7, &textureDlg2::OnBnClickedButton7)*/
	ON_LBN_SELCHANGE(IDC_LIST1, &textureDlg2::OnLbnSelchangeList1)
END_MESSAGE_MAP()


// textureDlg2 message handlers


void textureDlg2::setNewTypes(){
	objNames.ResetContent();
	for (int i = 0; i < objTypeArray.size();i++){
	//for (int i = objTypeArray.size() -1 ; i < 0;i--){
		
		objNames.AddString(_T((objNameArray[i] + " - " + objTypeArray[i]).c_str()));

	}

}


void textureDlg2::OnBnClickedButton1()
{
	if (objNameArray.size()>=1){
		ObjectTextureDlg dlg;
		if (dlg.DoModal() == IDOK){
			textureAns[0] = dlg.type;
			objTypeArray[0] = dlg.nameOfType;
			setNewTypes();
			
		}
	}
	
	// TODO: Add your control notification handler code here
}


void textureDlg2::OnBnClickedButton2()
{
	if (objNameArray.size()>=2){
		ObjectTextureDlg dlg;
		if (dlg.DoModal() == IDOK){
			textureAns[1] = dlg.type;
			objTypeArray[1] = dlg.nameOfType;
			setNewTypes();
		}
	}
}


void textureDlg2::OnBnClickedButton3()
{
	if (objNameArray.size()>=3){
		ObjectTextureDlg dlg;
		if (dlg.DoModal() == IDOK){
			textureAns[2] = dlg.type;
			objTypeArray[2] = dlg.nameOfType;
			setNewTypes();
		}
	}
}


void textureDlg2::OnBnClickedButton4()
{
	if (objNameArray.size()>=4){
		ObjectTextureDlg dlg;
		if (dlg.DoModal() == IDOK){
			textureAns[3] = dlg.type;
			objTypeArray[3] = dlg.nameOfType;
			setNewTypes();
		}
	}
}


void textureDlg2::OnBnClickedButton5()
{
	if (objNameArray.size()>=5){
		ObjectTextureDlg dlg;
		if (dlg.DoModal() == IDOK){
			textureAns[4] = dlg.type;
			objTypeArray[4] = dlg.nameOfType;
			setNewTypes();
		}
	}
}


void textureDlg2::OnBnClickedButton6()
{
	if (objNameArray.size()>=6){
		ObjectTextureDlg dlg;
		if (dlg.DoModal() == IDOK){
			textureAns[5] = dlg.type;
			objTypeArray[5] = dlg.nameOfType;
			setNewTypes();
		}
	}
}


void textureDlg2::OnBnClickedButton7()
{
	if (objNameArray.size()>=7){
		ObjectTextureDlg dlg;
		if (dlg.DoModal() == IDOK){
			textureAns[6] = dlg.type;
			objTypeArray[6] = dlg.nameOfType;
			setNewTypes();
		}
	}
}


void textureDlg2::OnLbnSelchangeList1()
{
	int sel = objNames.GetCurSel();
	ObjectTextureDlg dlg;
		if (dlg.DoModal() == IDOK){
			textureAns[sel] = dlg.type;
			objTypeArray[sel] = dlg.nameOfType;
			setNewTypes();
		}
	// TODO: Add your control notification handler code here
}
